package com.lin.mr.maizilaundry.myadapter;

import android.content.Context;
import android.support.v4.app.FragmentActivity;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.android.smartimage.SmartImageView;
import com.lin.mr.maizilaundry.R;
import com.lin.mr.maizilaundry.utils.ClothJean;
import com.lin.mr.maizilaundry.utils.WashInfoJean;

import java.util.List;

/**
 * Created by lenovog on 2016/8/15.
 */
public class VolleyAdapter extends BaseAdapter{
    private Context context;
    private List<ClothJean.ClothInfo> clothInfoList;
    private List<WashInfoJean.WashInfoBean> washInfoBeanList;

//    public VolleyAdapter(FragmentActivity activity, List<ClothJean.ClothInfo> list) {
//        this.context = activity;
//        this.clothInfoList = list;
//    }

    public VolleyAdapter(FragmentActivity activity, List<WashInfoJean.WashInfoBean> washInfoBeanList) {
        this.context = activity;
        this.washInfoBeanList = washInfoBeanList;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view = View.inflate(context, R.layout.fragment_volley_item,null);
        SmartImageView iv_image_cloth = (SmartImageView) view.findViewById(R.id.iv_image_cloth);
        TextView tv_cloth_name = (TextView) view.findViewById(R.id.tv_cloth_name);
        TextView tv_cloth_price = (TextView) view.findViewById(R.id.tv_cloth_price);
//        ClothJean.ClothInfo clothInfo = clothInfoList.get(position);
        WashInfoJean.WashInfoBean washInfoBean = washInfoBeanList.get(position);
        iv_image_cloth.setImageUrl(washInfoBean.getWashHead(),R.drawable.error2);
        tv_cloth_name.setText(washInfoBean.getWashName());
        tv_cloth_price.setText(washInfoBean.getAmount());
        return view;
    }

    @Override
    public int getCount() {
//        Log.e("GG",list.size()+"");
        if (washInfoBeanList!=null){
            return washInfoBeanList.size();
        }else {
            Log.e("TGG",washInfoBeanList+"");
            return 0;
        }
    }

    @Override
    public Object getItem(int position) {
        return position;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }
}
